﻿using Market.AbstractProduct;
using Market.Product;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Market
{
    /// <summary>
    /// 策略模式的上下文
    /// </summary>
    public class CashContext
    {
        CashSuper cs = null;
        /// <summary>
        /// 这边构造方法参数不直接传具体的策略，而是传输一个字符串，
        /// 表示收费类型（这里把简单工厂模式和策略模式结合）
        /// </summary>
        /// <param name="type"></param>
        public CashContext(string type)
        {
            switch (type)
            {
                case "正常收费":
                    cs = new CashNormal();
                    break;
                case "满 300 减 100":
                    cs = new CashReturn(300, 100);
                    break;
                case "打八折":
                    cs = new CashRebate(0.8);
                    break;
                default:
                    cs = new CashNormal();
                    break;
            }
        }

        public double GetResult(double money)
        {
            return cs.AcceptCash(money);
        }

    }
}
